package com.dudu.util;

import com.dudu.exception.ErrorCode;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dudu on 16/8/5.
 */
public class WebResponseHelper {

    public static <T> WebResponse<T> success() {
        return new WebResponse<T>();
    }

    public static <T> WebResponse<T> success(T data) {
        return new WebResponse<T>(data);
    }

    public static <T> WebResponse<T> success(T data, PageDto pageDto) {
        return new WebResponse<T>(data, pageDto);
    }

    public static <T> WebResponse<T> error() {
        return new WebResponse<T>(ErrorCode.UNKNOW);
    }

    public static <T> WebResponse<T> error(ErrorCode errorCode) {
        return new WebResponse<T>(errorCode);
    }

    public static <T> WebResponse<T> error(ErrorCode errorCode, String msg) {
        return new WebResponse<T>(errorCode, msg);
    }

    public static WebResponse<?> successData() {
        Map<String, Object> map = new HashMap<String, Object>();
        return new WebResponse<>(map);
    }
}
